﻿<?php

/**
 * Klasse sendEmail
 * @param  : $strMailFrom, $strNameFrom, $strMailTo, $strNameTo, $strSubject, $strBody
 *
 * @info   : Versenden der eMail an die Verwaltungs-Anwendung, Contend=XML String
 *
 * @e.datum : 12.12.2010
 * @l.datum : 30.12.2010
 * @version: beta
 * */
class sendEmail {

    private $strMailFrom = '';
    private $strNameFrom = '';
    private $strMailTo = '';
    private $strNameTo = '';
    private $strSubject = '';
    private $strBody = '';

    /**
     * Konstruktor sendMail
     * @param : $body (mail-xml)
     * */
    public function __construct($body) {
        $this->strMailFrom = 'test@HHEK-Projekt.de';
        $this->strNameFrom = 'Projektteam';
        $this->strMailTo = 'anmeldung@hhek.bonn.de';
        $this->strNameTo = 'Anmeldung';
        $this->strSubject = 'Anmeldung HHEK';
        $this->strBody = $body;
    }

    /**
     * Destruktor sendMail
     * @param : ..
     * */
    public function __destruct() {
        $this->strMailFrom = null;
        $this->strNameFrom = null;
        $this->strMailTo = null;
        $this->strNameTo = null;
        $this->strSubject = null;
        $this->strBody = null;
    }

    /**
     * fuSending
     * @param : ..
     * */
    public function fuSendingData() {
        include('config.inc.php');
        mail($this->strMailTo, $this->strSubject, $this->strBody);
//    require_once 'Zend/Mail.php';
//    $mail = new Zend_Mail();
//    $mail->setBodyText($this->strBody);
//    $mail->setFrom($this->strMailFrom, $this->strNameFrom);
//    $mail->addTo($this->strMailTo, $this->strNameTo);
//    $mail->setSubject($this->strSubject);
//    $mail->send();
//    $mail=null;
    }

    /**
     * fuSending
     * @param : ..
     * */
    public function fuSendingForm() {
        include('config.inc.php');
        include('/classes/pdf.php');

        $message;
        if ($_SESSION['AusbilderAnrede'] == "Herr") {
            $message .= "Sehr geehrter Herr " . $_SESSION['AusbilderName'] . ",\r\n\r\n";
        } else {
            $message .= "Sehr geehrte Frau " . $_SESSION['AusbilderName'] . ",\r\n\r\n";
        }

        $message .= "Ihr Auszubildender / Ihre Auszubildende wurde online als $_SESSION[Beruf] angemeldet. am Heinrich-Hertz-Europakolleg angemeldet. Sie würden als Ausbilder genannt. \r\n\r\n";
        $message .= "Eine Kopie des Anmeldeformular finden Sie im Anhang. \r\n\r\n";
        $message .= "Mit freundlichen Grüßen\r\n\r\n";
        $message .= "Online-Anmeldung des Heinrich-Hertz-Europakolleg";
        $message .= "https://www.hhek.bonn.de/anmeldung/";



        $absender = "Onlineanmeldung HHEK";
        $absender_mail = "noreply@hhek.bonn.de";
        $reply = "noreply@hhek.bonn.de";

        $mime_boundary = "-----=" . md5(uniqid(mt_rand(), 1));

        $header = "From:" . $absender . "<" . $absender_mail . ">\n";
        $header .= "Reply-To: " . $reply . "\n";

        $header.= "MIME-Version: 1.0\n";
        $header.= "Content-Type: multipart/mixed;\n";
        $header.= " boundary=\"" . $mime_boundary . "\"\n";

        $content = "This is a multi-part message in MIME format.\n";
        $content.= "--" . $mime_boundary . "\n";
        $content.= "Content-Type: text/plain charset=\"iso-8859-1\"\n";
        $content.= "Content-Transfer-Encoding: 8bit\n\n";
        $content.= $message . "\n";


        $pdf = new createPDF();
        $pdfString = $pdf->fuCreatePDF(false);
        $data = chunk_split(base64_encode($pdfString));
        $content.= "--" . $mime_boundary . "\n";
        $content.= "Content-Disposition: attachment;\n";
        $content.= " filename=\"" . "Anmeldeformular.pdf" . "\";\n";
        $content.= "Content-Length: " . strlen($pdfString) . ";\n";
        $content.= "Content-Type: " . "application/pdf" . "; name=\"Anmeldeformular.pdf\"\n";
        $content.= "Content-Transfer-Encoding: base64\n\n";
        $content.= $data . "\n";
        $content.= "--" . $mime_boundary . "\n";

        mail($_SESSION['AusbilderEmail'], "Onlineanmeldung HHEK", $content, $header);
    }

}

?>